package com.qf.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qf.mapper.DtsCollectMapper;
import com.qf.pojo.DtsCollect;
import com.qf.service.DtsCollectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * @version 1.0
 * @auther Administrator
 * @date 2023/2/24 14:30
 */
@Service
public class DtsCollectServiceImpl implements DtsCollectService {
    @Autowired
    private DtsCollectMapper dtsCollectMapper;

    @Override
    public IPage<DtsCollect> findListByQuery(Integer page, Integer limit, String sort, String order, Integer userId, Integer valueId) {
        return dtsCollectMapper.selectPage(new Page(page,limit)
                ,new QueryWrapper<DtsCollect>()
                    .like(!StringUtils.isEmpty(userId),"user_id",userId).like(!StringUtils.isEmpty(valueId),"value_id",valueId)
                    .orderBy(!StringUtils.isEmpty(sort),"ASC".equalsIgnoreCase(order),sort));
    }
}
